package com.youmu.sichuansfc.controller;

import com.youmu.sichuansfc.common.CommonRes;
import com.youmu.sichuansfc.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 *
 * 拉取地址
 * @author WYZ
 * @create 2018-02-26 14:28
 * @desc
 **/
@Controller
public class AreaController {


    @Autowired
    AreaService areaService;

    /**
     *  拉取地址
     * @param id 该ID下级城市
     * @return
     */
    @RequestMapping(value = "/area", method = RequestMethod.GET)
    public @ResponseBody
    CommonRes getArea(@RequestParam(name = "id", required = false) Long id){

        try {
            return CommonRes.success(areaService.findArea(id));
        }catch (Exception e){
            e.printStackTrace();
        }
        return  CommonRes.fail();
    }

}
